﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Convertor.Code.Validation
{
    class TemplateName : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                return new ValidationResult(false, "IsEmpty");
            }
            else
            {
                var a = Config.GlobalConfig.TemplateList.Where(k => k.Name == value.ToString()).FirstOrDefault();
                if (a == null)
                {
                    return new ValidationResult(true, null);
                }
                else
                {
                    return new ValidationResult(false, "TemplateNameExist");
                }
            }
        }
    }
}
